package com.ketai.util;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author:长沙科泰梦想学院
 * @Description: 分页的工具类  封装了分页需要用到的5个参数
 * @Date:Create In 2022/6/21 14:20
 **/
public class Pages<T> {
    // 每页显示的数量
    private Integer pageNumber;
    // 符合查询条件的总数据数量
    private Long dataTotal;
    // 总页数
    private Integer totalPages;
    // 当前页面
    private Integer currentPage;
    // 当前页查询的数量集合
    private List<T> dataItems = new ArrayList<>();


    public Integer getPageNumber () {
        return pageNumber;
    }

    public void setPageNumber (Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    public Long getDataTotal () {
        return dataTotal;
    }

    public void setDataTotal (Long dataTotal) {
        this.dataTotal = dataTotal;
    }

    public Integer getTotalPages () {

        return totalPages;
    }

    public  void  setTotalPages (int totalPages) {
        // 计算总页数
        this.totalPages =totalPages;
    }


    public Integer getCurrentPage () {
        return currentPage;
    }

    public void setCurrentPage (Integer currentPage) {
        // 对传进来的当前页参数进行校验

        if (currentPage <= 0) {
            currentPage = 1;
        } else if (currentPage > totalPages) {
            currentPage = totalPages;
        }

        this.currentPage = currentPage;
    }

    public List<T> getDataItems () {
        return dataItems;
    }

    public void setDataItems (List<T> dataItems) {
        this.dataItems = dataItems;
    }
}
